#include <bits/stdc++.h>

using namespace std;
int main(){
	string s1,s2;
	getline(cin,s1);
	getline(cin,s2);
	int len1,len2;
	len1 = s1.size();
	len2 = s2.size();
	int i=0,j=0,len=0,maxlen=0,star=0;
	int h;
	while( len1>j ){
		i=0;
		while( len2>i ){
			h = j;
			len = 0;
			int flag = i;
			while( h<len1||flag<len2 ){
				if( s1[h] != s2[flag] ) break;
				h++;
				len++;
				flag++;
			}
			if( len>maxlen ){
				maxlen = len;
				star = j;
			}
			i++;
		}
		j++;
	}
	if( maxlen == 0 ) cout<<"NULL";
	while( maxlen-- ){
		cout<<s1[star];
		star++;
	}
} 
